package com.golookon.managed;

import java.io.Serializable;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Map;
import java.util.List;

import org.primefaces.event.ItemSelectEvent;
import org.primefaces.model.chart.PieChartModel;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@SuppressWarnings("serial")
@Component("chartBean")
@Scope("session")
public class ChartBean implements Serializable {
	private PieChartModel pieModel;
	private String selectedItem;
	private Map<String, List<String>> menu;
	private List<String> currentList;

	public ChartBean() {
		createPieModel();
		createMenu();
		selectedItem = "Sandwiches";
	}	
	public List<String> getCurrentList() {
		return currentList;
	}
	public void setCurrentList(List<String> currentList) {
		this.currentList = currentList;
	}
	public Map<String, List<String>> getMenu() {
		return menu;
	}
	public void setMenu(Map<String, List<String>> menu) {
		this.menu = menu;
	}


	public PieChartModel getPieModel() {
		return pieModel;
	}

	public String getSelectedItem() {
		return selectedItem;
	}

	public void setSelectedItem(String selectedItem) {
		this.selectedItem = selectedItem;
	}

	public void itemSelect(ItemSelectEvent event) {
		switch (event.getItemIndex()) {
		case 0:
			selectedItem = "Pastries";
			break;
		case 1:
			selectedItem = "Sandwiches";
			break;
		case 2:
			selectedItem = "Soups";
			break;
		case 3:
			selectedItem = "Drinks";
			break;
		case 4:
			selectedItem = "Breads";
			break;
		case 5:
			selectedItem = "Bagels";
			break;
		case 6:
			selectedItem = "Salads";
			break;
		case 7:
			selectedItem = "Breakfast";
			break;

		default:
			selectedItem = "";
			break;
		}
		currentList = getListByName(selectedItem);
		/*
		 * FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO,
		 * "Item selected", "Item Index: " + event.getItemIndex() +
		 * ", Series Index:" + event.getSeriesIndex());
		 * 
		 * FacesContext.getCurrentInstance().addMessage(null, msg);
		 */
	}

	private void createPieModel() {
		pieModel = new PieChartModel();

		pieModel.set("Pastries", 100);
		pieModel.set("Sandwiches", 100);
		pieModel.set("Soups", 100);
		pieModel.set("Drinks", 100);
		pieModel.set("Breads", 100);
		pieModel.set("Bagels", 100);
		pieModel.set("Salads", 100);
		pieModel.set("Breakfast", 100);
	}

	private void createMenu() {
		menu = new HashMap<String, List<String>>();
		List<String> sandwichesList = new ArrayList<String>();
		sandwichesList.add("Bacon Turkey Bravo on Tomato Basil");
		sandwichesList.add("Chicken Caesar on Three Cheese");
		sandwichesList.add("Italian Combo on Ciabatta");
		sandwichesList.add("Napa Almond Chicken Salad on Sesame Semolina");
		sandwichesList.add("Asiago Roast Beef on Asiago Cheese");
		sandwichesList.add("Roasted Turkey & Avocado BLT on Sourdough");
		sandwichesList.add("Sierra Turkey on Asiago Cheese Focaccia");
		sandwichesList.add("Smoked Turkey Breast on Country");
		sandwichesList.add("Tuna Salad on Honey Wheat");
		menu.put("Sandwiches", sandwichesList);

		List<String> soupsList = new ArrayList<String>();
		soupsList.add("Soup in a Sourdough Bread Bowl*");
		soupsList.add("Soup For A Group");
		soupsList.add("Bowl of Soup*");
		menu.put("Soups", soupsList);

		List<String> drinksList = new ArrayList<String>();
		drinksList.add("Frozen Lemonade");
		drinksList.add("Frozen Caramel");
		drinksList.add("Frozen Mocha");
		drinksList.add("Frozen Mango");
		menu.put("Drinks", drinksList);

		List<String> breadsList = new ArrayList<String>();
		breadsList.add("Sourdough");
		breadsList.add("All-Natural White");
		breadsList.add("Asiago Cheese");
		breadsList.add("Tomato Basil");
		breadsList.add("Honey Wheat");
		breadsList.add("Cinnamon Raisin");
		breadsList.add("Three Seed");
		breadsList.add("Whole Grain");
		breadsList.add("Stone-Milled Rye");
		breadsList.add("Sesame Semolina");
		menu.put("Breads", breadsList);

		List<String> bagelsList = new ArrayList<String>();
		bagelsList.add("Bagels");
		bagelsList.add("aker’s Dozen (13 bagels)");
		bagelsList.add("Bagel Pack (13 bagels, two tubs of spreads)");
		bagelsList.add("Cream Cheese Spread");
		bagelsList
				.add("Bagels -- With premium ingredients and delectable combinations of flavors, our signature bagel line is irresistible. Chocolate Chip, French Toast, Blueberry, Cinnamon Swirl & Raisin, Sweet Onion & Poppyseed, Cinnamon Crunch, Asiago Cheese");
		bagelsList.add("Dozen & a Half (18 bagels)");
		menu.put("Bagels", bagelsList);

		List<String> saladsList = new ArrayList<String>();
		saladsList.add("BBQ Chopped Chicken");
		saladsList.add("Thai Chopped Chicken");
		saladsList.add("Asian Sesame Chicken");
		saladsList.add("Fuji Apple Chicken");
		saladsList.add("Grilled Chicken Caesar");
		saladsList.add("Greek");
		saladsList.add("Classic");
		saladsList.add("Caesar");		
		menu.put("Salads", saladsList);

		List<String> breakfastList = new ArrayList<String>();
		breakfastList.add("Signature Breakfast Sandwiches");
		breakfastList.add("Breakfast Power Sandwich on Whole Grain");
		breakfastList.add("Ciabatta Breakfast Sandwiches");
		breakfastList.add("Mediterranean Egg White on Ciabatta");
		breakfastList.add("Baked Egg Soufflés");
		menu.put("Breakfast", breakfastList);

		List<String> pastriesList = new ArrayList<String>();
		pastriesList.add("Artisan Pastries");
		pastriesList.add("Scones");
		pastriesList.add("Muffins");
		pastriesList.add("Sweet Rolls");
		menu.put("Pastries", pastriesList);

	}
	
	public List<String> getListByName(String name){
		return menu.get(name);
	}

}
